﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Web.UI;

namespace CustomControlPractice
{
    public partial class TreeSelectionPanel_Debug : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var hospital1 = new Hospital("Xiehe",1);
            var hospital2 = new Hospital("Huadong", 2);
            var hospital3 = new Hospital("Xiangya",3);
            for(int i=1;i<5;i++)
            {
                var department = new Department(string.Format("Department{0}",i), i);
                hospital1.Departments.Add(department);
                hospital2.Departments.Add(department);
                hospital3.Departments.Add(department);
            }

            var hospitals = new List<Hospital> {hospital1, hospital2, hospital3};

            treeSelectionPanel.BindData(hospitals);
        }

        protected void OnButtonClick(object sender, EventArgs e)
        {
            var selected = treeSelectionPanel.Selected;
        }
    }

    public class Hospital  
    {
        private List<Department> departments;

        public string Name { get; set; }
        public int ID { get; set; }

        public Hospital(string name,int id)
        {
            Name = name;
            ID = id;
            departments = new List<Department>();
        }

        public List<Department> Departments 
        { 
            get { return departments; }
        }
    }

    public class Department     
    {
        public Department(string name,int id)
        {
            Name = name;
            ID = id;
        }

        public string Name { get; set; }
        public int ID { get; set; }
    }

}